package cn.cnf.mapper;

import cn.cnf.entity.Comic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * (comic)数据Mapper
 *
 * @author ZhuMeiYi
 * @description
 * @since 2020-12-04 17:12:13
 */
@Mapper
public interface ComicMapper extends BaseMapper<Comic> {

    @Update("update comic set subscribe_num = (subscribe_num + #{number}) where comic.id = #{subscribeId}")
    Integer updateSubscribe(@Param("subscribeId") String subscribeId, @Param("number") int number);

    IPage<Comic> selectVerifyingList (Page<Comic> page);

    List<Comic> getRecentlyUpdate(Page<Comic> page);

    @Update("update comic set income = #{income} where comic.id = #{comicId}")
    Integer updateIncome(@Param("comicId") String comicId, @Param("income") BigDecimal income);

    @Update("update comic set recommend = #{value} where comic.id = #{comicId}")
    Integer updateRecommend(String comicId, Integer value);

    @Update("update comic set verify_state = #{value} where comic.id = #{comicId}")
    Integer updateVerify(String comicId, Integer value);

    @Update("update comic set collect_num = #{value} where comic.id = #{comicId}")
    Integer updateCollectNum(@Param("comicId") String comicId, @Param("value") Integer value);

    @Update("update comic set comment_num = #{value} where comic.id = #{comicId}")
    Integer updateCommentNum(@Param("comicId") String comicId, @Param("value") Integer value);

    @Update("update comic set state = #{state} where comic.id = #{comicId}")
    Integer updateState(String comicId, Integer state);
}
